﻿using OperationPlugins.Mvc.Filters;
using System.Web.Mvc;
using TimeProject.Engine;
using TimeProject.Engine.DbModels;
using WebMatrix.WebData;

namespace TimeProject.WebSite.Controllers
{
    public partial class TimeProjectController
    {
        [HttpPost]
        [CurrentOperation(TimeProjectOperations.LogOff)]
        [ValidateAntiForgeryToken]
        public ActionResult LogOff()
        {            
            Db.UserActivities.Add(new UserActivity { UserId = UserId, Type = UserActivityType.Logout });

            SaveDbContext();

            WebSecurity.Logout();
            return RedirectToAction("Login");
        }

    }
}